def movable(maze,coordinate):
    row,col=coordinate
    return row >= 0 and row <= len(maze)-1 \
           and col >=0 and col <= len(maze[0])-1 \
           and maze[row][col] == '1'

def find_route(maze,start,end):
    row,col=start
    maze[row][col]='*'
    if start == end:
        for i in range(len(maze)):
            print(maze[i])
    right=row,col+1
    down=row+1,col
    left=row,col-1
    up=row-1,col
    if movable(maze,right):
        find_route(maze,right,end)
        maze[row][col+1]='1'
    if movable(maze,down):
        find_route(maze,down,end)
        maze[row+1][col]='1'
    if movable(maze,left):
        find_route(maze,left,end)
        maze[row][col-1]='1'
    if movable(maze,up):
        find_route(maze,up,end)
        maze[row-1][col]='1'

maze=[['1','0','1','1','1'],
      ['1','1','1','0','1'],
      ['1','0','0','1','1'],
      ['1','0','0','1','0'],
      ['1','0','0','1','1']]

find_route(maze,(0,0),(4,4))
